<?php
/**
 * 专门提供数据的控制器
 * @Author 聂哥<376927050@qq.com>
 * @Date: 2022-10-12 11:27:48
*/
namespace app\admin\controller\system;

use app\admin\service\MenuService;

class Data
{
    /**
     * 后台左侧菜单
     * @MethodAuthor: 聂哥
     * @Date: 2022-10-28 15:32:09
     */
    public function menu($module = 1)
    {
        $key = sprintf("%s_%s_menulist",
            session('admin.id'),
            session('current_module_name')
        );
        if( ($menuTree = cache($key)) == null ){
            $userRoleIds = session('admin.role_ids');
            $menuData = MenuService::getSystemMenuListByRole($userRoleIds,session('current_module_name'));
            $menuTree = get_tree($menuData);
            cache($key,$menuTree);
        }
        return json($menuTree);
    }

    /**
     * 后台右上角新消息
     * @MethodAuthor: 聂哥
     * @Date: 2022-11-02 01:32:09
     */
    public function message()
    {
        return json([]);
    }
}